package Map遍历;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;
//2.通过键值对象遍历
public class MapDemo3 {
    public static void main(String[] args) {
        Map<String,String> map=new HashMap<>();
        map.put("杨坤伦","潭淏");
        map.put("张家地","张天宇");
        map.put("潭狗","付林立");
        //通过entrySet获取所有键值对象,放入set集合中
        Set<Map.Entry<String,String>> entries=map.entrySet();
        //增强for遍历
        for (Map.Entry<String, String> entry : entries) {
            //通过getKey得到键,通过getValue得到值
            System.out.println(entry.getKey()+"="+entry.getValue());
        }
    }
}
